package d7_homework.d2_programmingquestions.thirddemo;

import java.util.Scanner;

public class ATM {
    private static AtmServiceImpl i = new AtmServiceImpl();
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        //创建扫描器

        //提示用户输入
        System.out.println("====欢迎来到取款界面=======");

        //创建金额操作对象;

        while (true) {
            try {
                System.out.println("请输入您的取款金额");
                double getMoney = sc.nextDouble();
                i.drawMoney(getMoney);
                System.out.println("恭喜您取款成功");
                break;
            } catch (RuntimeException e) {
                System.out.println("取款失败,请按照提示从新操作");
                System.out.println(e.getMessage());
            }
        }

        System.out.println("您的余额是: " + i.getBalance());
    }
}
